import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * JDBC 连接
 * @author shengren.yan
 * @create 2023-08-25
 */
public class t1 {


    /**
     * 连接mysql服务
     *
     * @param args arg游戏
     */
    public static void main(String[] args) {
        try {
            // 提供 url, user, password
            String url="jdbc:mysql://localhost:3306/库?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8";
            String user="用户名";
            String password="密码";
            Class.forName("com.mysql.cj.jdbc.Driver");
            // 获取连接
            Connection connection = DriverManager.getConnection(url, user, password);
            System.out.println(connection);
        } catch (ClassNotFoundException | SQLException e) {
            e.printStackTrace();
        }
    }

}
